package  
{
	import flash.display.MovieClip;
	/**
	 * ...
	 * @author Seven Gae
	 */
	public class FlashingBackground 
	{
		private var staticBackground:MovieClip;
		private var flashingBackground:MovieClip;
		private var velocity:Number;
		private var acelerting:Boolean;
		
		public function FlashingBackground():void
		{
			staticBackground = new Fundo();
			Main.Self.screen.addChild(staticBackground);
			flashingBackground = new FundoClaro();
			Main.Self.screen.addChild(flashingBackground);
			flashingBackground.alpha = 0;
			acelerting = true;
			velocity = 0;
		}
		
		public function update():void
		{
			if (acelerting)
				velocity += 0.005;
			else
				velocity -= 0.008;
				
			flashingBackground.alpha += velocity;
			
			if (flashingBackground.alpha >= 1)
			{
				acelerting = false;
				velocity = 0;
			}
			else if (flashingBackground.alpha <= 0)
			{
				acelerting = true;
				velocity = 0;

			}
		}
		
		public function destroy():void
		{
			Main.Self.screen.removeChild(staticBackground);
			Main.Self.screen.removeChild(flashingBackground);
		}
		
	}

}